package com.party.core.service.analysis.impl;

import com.party.common.paging.Page;
import com.party.core.dao.read.analysis.StatisticsUserReadDao;
import com.party.core.dao.write.analysis.StatisticsUserWriteDao;
import com.party.core.model.BaseModel;
import com.party.core.model.analysis.StatisticsUser;
import com.party.core.model.analysis.StatisticsUserVisit;
import com.party.core.service.analysis.IStatisticsUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * @program: party-temp
 * @description: 统计用户接口实现
 * @author: Huaqunhao
 * @create: 2018-08-01 15:40
 **/

@Service
public class StatisticsUserService implements IStatisticsUserService {

    @Autowired
    private StatisticsUserReadDao statisticsUserReadDao;
    @Autowired
    private StatisticsUserWriteDao statisticsUserWriteDao;
    @Override
    public String insert(StatisticsUser statisticsUser) {
        BaseModel.preInsert(statisticsUser);
        boolean result = statisticsUserWriteDao.insert(statisticsUser);
        if (result){
            return statisticsUser.getId();
        }
        return null;
    }

    @Override
    public boolean update(StatisticsUser statisticsUser) {
        statisticsUser.setUpdateDate(new Date());
        return statisticsUserWriteDao.update(statisticsUser);
    }

    @Override
    public boolean deleteLogic(String id) {
        return false;
    }

    @Override
    public boolean delete(String id) {
        return statisticsUserWriteDao.delete(id);
    }

    @Override
    public boolean batchDeleteLogic(Set<String> ids) {
        return false;
    }

    @Override
    public boolean batchDelete(Set<String> ids) {
        return false;
    }

    @Override
    public StatisticsUser get(String id) {
        return statisticsUserReadDao.get(id);
    }

    @Override
    public List<StatisticsUser> listPage(StatisticsUser statisticsUser, Page page) {
        return statisticsUserReadDao.listPage(statisticsUser,page);
    }

    @Override
    public List<StatisticsUser> list(StatisticsUser statisticsUser) {
        return null;
    }

    @Override
    public List<StatisticsUser> batchList(Set<String> ids, StatisticsUser statisticsUser, Page page) {
        return null;
    }

    @Override
    public StatisticsUser getByUserId(String userId) {
        return statisticsUserReadDao.getByUserId(userId);
    }

    @Override
    public StatisticsUserVisit countNewAndOldUsersCount(Map<String, Object> map) {
        return statisticsUserReadDao.countNewAndOldUsersCount(map);
    }

    @Override
    public List<StatisticsUser> queryUserListByDate(String queryDate, Page page) {
        return statisticsUserReadDao.queryUserListByDate(queryDate,page);
    }

    @Override
    public int queryUserCountByDate(String queryDate, Integer total) {
        return statisticsUserReadDao.queryUserCountByDate(queryDate,total);
    }

    @Override
    public void deleteUserByQueryDate(String queryDate, Integer total) {
        statisticsUserWriteDao.deleteUserByQueryDate(queryDate,total);
    }
}
